package yto.freemarker.springcloud.service;

import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;
import yto.freemarker.springcloud.entity.User;

/**
 * @author dongxing
 * @create 2018-03-02 15:15
 **/
@Component
public class HystrixClientFallbackFactory implements FallbackFactory<UserService> {
    @Override
    public UserService create(Throwable throwable) {
        return new UserService() {
            @Override
            public User getUserById(String id) {
                //日记最好放在每个方法的内部
                return User.builder().username("失败1").build();
            }

            @Override
            public User postUser(User user) {
                return User.builder().username("失败2").build();
            }
        };
    }
}
